/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.javanile.jclient;

import java.io.*;
import javax.microedition.io.*;
/**
 *
 * @author Lara
 */
public class Http {
    public static String GET(String url) {
        HttpConnection c = null;
        InputStream is = null;
        StringBuffer sb = new StringBuffer();
        try {
          c = (HttpConnection)Connector.open(url, Connector.READ_WRITE, true);
          c.setRequestMethod(HttpConnection.GET); //default
          is = c.openInputStream(); // transition to connected!
          int ch = 0;
          for(int ccnt=0; ccnt < 150; ccnt++) { // get the title.
            ch = is.read();
            if (ch == -1){
              break;
            }
            sb.append((char)ch);
          }
        }
        catch (IOException x){
                x.printStackTrace();
        }
        finally{
             try     {
               is.close();
                  c.close();
             } catch (IOException x){
                  x.printStackTrace();
             }
        }
        //System.out.println(sb.toString());
        return sb.toString();
    }
}
